package com.woniu.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniu.project.core.domain.ProductEntityAssess;
import com.woniu.project.core.dto.ResultDto;
import com.woniu.project.dto.assessdto.AssessDto;
import com.woniu.project.params.assessparams.AssessConditionParams;
import com.woniu.project.params.assessparams.AssessParams;
import com.woniu.project.service.IProductEntityAssessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author WHF
 * @since 2020-10-13
 */
@RestController
@RequestMapping("/assess")
@Slf4j
@Api(tags = "assess控制层")
public class ProductEntityAssessController {

    @Autowired
    private IProductEntityAssessService productEntityAssessService;

    /**
     * 新增评估记录
     * @param assessParams 评估记录对象
     * @return
     */
    @ApiOperation(value = "新增评估记录",notes = "productEntityId,assessManId,productEntityAssessPrice必填")
    @PostMapping("insertAssess")
    public ResultDto insertAssess(@Valid @RequestBody AssessParams assessParams){
        log.info("新增一条评估记录时传入的对象为：{}",assessParams);

        productEntityAssessService.insertAssess(assessParams);
        return ResultDto.success(200,"新增成功",null);
    }

    /**
     * 分页查询单个商品下的所有历史评估记录
     * @param assessConditionParams 查询条件参数对象
     * @return
     */
    @ApiOperation(value = "查询评估记录",notes = "productEntityId必填")
    @GetMapping("selectAssessList")
    public ResultDto selectAssessList(AssessConditionParams assessConditionParams){
        log.info("查询评估记录时传入的id为：{}",assessConditionParams);
        IPage<AssessDto> assessDtoIPage = productEntityAssessService.selectAssessList(assessConditionParams);
        return ResultDto.success(assessDtoIPage);
    }

}

